package com.example.kotlin.handler

import com.example.kotlin.extension.*
import com.example.kotlin.model.*
import org.springframework.stereotype.*
import xyz.erupt.annotation.`fun`.*
import xyz.erupt.jpa.dao.*
import javax.annotation.*

@Component
class GetAllCategories : ChoiceFetchHandler {

    @Resource
    private lateinit var eruptDao: EruptDao

    // 获取到所有的班级名,放进下拉列表中
    override fun fetch(params: Array<out String>?): List<VLModel> {
        return eruptDao.queryEntityList<Category>().map { VLModel(it.id.toString(), it.name) }.toList()
    }
}
